package idv.cjcat.pyronova.nodes {
	import flash.filters.BlurFilter;
	import flash.geom.Point;
	import idv.cjcat.pyronova.render.Graphics;
	import idv.cjcat.pyronova.render.RenderVisitor;
	
	public class Blur extends Node {
		
		private var _amount:Number;
		public function get amount():Number { return _amount; }
		public function set amount(value:Number):void {
			_filter.blurX = _filter.blurY = _amount = value;
		}
		
		private var _quality:int;
		public function get quality():int { return _quality; }
		public function set quality(value:int):void {
			_filter.quality = _quality = value;
		}
		
		private var _filter:BlurFilter;
		
		public function Blur(amount:Number = 4, quality:int = 1) {
			_filter = new BlurFilter();
			this.amount = amount;
			this.quality = quality;
		}
		
		private var g:Graphics;
		private var point:Point = new Point();
		override public function render(visitor:RenderVisitor):void {
			g = visitor.graphics();
			g.topBuffer().applyFilter(g.topBuffer(), g.rect(), point, _filter);
		}
	}
}